/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package csvreader.controller;

import java.awt.Component;
import java.awt.Container;
import java.util.List;
import java.util.ArrayList;
import javax.swing.JTextField;

/**
 *
 * @author User
 */
public class ResetText {

    private static boolean isJTextField(Component c) {
        boolean kondisi = false;

        try {
            JTextField jt = (JTextField) c;
            kondisi = true;
        } catch (Exception e) {
        }
        return kondisi;
    }
    private static Component[] comp;
    private static List<Component> listComp;

    public static List<Component> resetJTextField(final Container cont) {
        comp = cont.getComponents();
        listComp = new ArrayList<Component>();
        for (Component c : comp) {
            listComp.add(c);
            if (isJTextField(c)) {
                JTextField jt = (JTextField) c;
                if (jt.isEditable()) {
                    jt.setText(null);
                }
            }
            
            if(c instanceof Container){
                listComp.addAll(resetJTextField((Container) c));
            }

        }
        return listComp;
    }
}
